<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <!--<a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="图片">
              <a-input placeholder="请输入图片" v-model="queryParam.banner"></a-input>
            </a-form-item>
          </a-col>-->


          <!--<a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>-->

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <!--<a-button type="primary" icon="download" @click="handleExportXls('轮播图管理')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <!--<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="bannerslot" slot-scope="text, record, index">
          <div class="anty-img-wrap">
            <a-avatar shape="square" :src="getBannerView(record.banner)" icon="user"/>
          </div>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>

        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <gBanner-modal ref="modalForm" @ok="modalFormOk"></gBanner-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import GBannerModal from './modules/GBannerModal'
  import {putAction,getFileAccessHttpUrl} from '@/api/manage';
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: "GBannerList",
    mixins:[JeecgListMixin],
    components: {
      GBannerModal
    },
    data () {
      return {
        description: '轮播图管理管理页面',
        isorter:{
          column: 'indexP',
          order: 'asc',
        },
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
		   {
            title: '图片',
            align:"center",
            dataIndex: 'banner',
            scopedSlots: {customRender: "bannerslot"},
            width: "40%"
           },
		   {
            title: '排序',
            align:"center",
            dataIndex: 'indexP'
           },
          {
            title: '公告标题',
            align:"center",
            dataIndex: 'remark1'
          },
		   /*{
            title: '0:正常,1:删除',
            align:"center",
            dataIndex: 'delflag'
           },
		   {
            title: 'remark',
            align:"center",
            dataIndex: 'remark'
           },
		   {
            title: 'remark2',
            align:"center",
            dataIndex: 'remark2'
           },
		   {
            title: 'remark3',
            align:"center",
            dataIndex: 'remark3'
           },
		   {
            title: 'remark4',
            align:"center",
            dataIndex: 'remark4'
           },
		   {
            title: 'remark5',
            align:"center",
            dataIndex: 'remark5'
           },
		   {
            title: 'remark6',
            align:"center",
            dataIndex: 'remark6'
           },
		   {
            title: 'remark7',
            align:"center",
            dataIndex: 'remark7'
           },
		   {
            title: 'remark8',
            align:"center",
            dataIndex: 'remark8'
           },
		   {
            title: 'remark9',
            align:"center",
            dataIndex: 'remark9'
           },
		   {
            title: 'remark10',
            align:"center",
            dataIndex: 'remark10'
           },*/
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/gbanner/gBanner/list",
          delete: "/gbanner/gBanner/delete",
          deleteBatch: "/gbanner/gBanner/deleteBatch",
          exportXlsUrl: "gbanner/gBanner/exportXls",
          importExcelUrl: "gbanner/gBanner/importExcel",
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
      getBannerView: function (banner) {
        return getFileAccessHttpUrl(banner)
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .anty-img-wrap {
    width: 100%;
    height: auto;
    position: relative;
  }
  .ant-avatar,.ant-avatar-square,.ant-avatar-image,.ant-avatar-icon{
    width: 40%;
    height: 100%;
  }
  .ant-avatar img{
    width: 100%;
    height: 100%;
  }
</style>